Skip to content

fix(apps/ensadmin): keep open ENSAdmin GraphiQL docs sidebar#2001

Merged
shrugs merged 5 commits intomainfrom
notrab/fix-ensadmin-graphiql-introspection-loop
Apr 29, 2026
Merged

fix(apps/ensadmin): keep open ENSAdmin GraphiQL docs sidebar#2001
shrugs merged 5 commits intomainfrom
notrab/fix-ensadmin-graphiql-introspection-loop

Conversation

@notrab
Copy link
Copy Markdown
Member

@notrab notrab commented Apr 27, 2026

…pen on the omnigraph page. The editor now memoizes its fetcher, storage, and plugins so 1Hz parent re-renders (driven by the realtime indexing-status projection) no longer trigger schema re-introspection

Lite PR

Tip: Review docs on the ENSNode PR process

Summary

  • Memoize the GraphiQL fetcher, storage, and plugins in apps/ensadmin/src/components/graphiql-editor/components.tsx so they keep stable references across renders.
  • Hoist the plugins = [] default to a module-level constant so it doesn't bust the memo on every render.
  • Move the if (!url || typeof window === "undefined") early-return below the hooks to keep hook order stable.

Why

The omnigraph page's parent ticks once per second via useNow({ timeToRefresh: 1 }) inside useIndexingStatusWithSwr (driving the realtime indexing-status projection).

The GraphiQLEditor was rebuilding its fetcher, storage, and explorer plugin on every render, and GraphiQL re-runs schema introspection whenever the fetcher reference changes. Net result: the docs sidebar would never stay open and the schema was re-fetched every sec.


Testing

  • How this was tested.
  • If you didn't test it, say why.

Notes for Reviewer (Optional)

  • The 10s /api/indexing-status refetch and th realtime-projection re-renders are both intentional and unchanged by this PR.
  • You can verify against any ENSNode server that has been redeployed since Extend stack info data model #1988 (or by running ensindexer + ensapi locally from this branch). Expected behaviour: a single introspection request, /api/indexing-status polled every 10s, docs sidebar opens and stays open.

Pre-Review Checklist (Blocking)

  • This PR does not introduce significant changes and is low-risk to review quickly.
  • Relevant changesets are included (or are not required)

…pen on the omnigraph page. The editor now memoizes its fetcher, storage, and plugins so 1Hz parent re-renders (driven by the realtime indexing-status projection) no longer trigger schema re-introspection
Copilot AI review requested due to automatic review settings April 27, 2026 11:06
@notrab notrab requested a review from a team as a code owner April 27, 2026 11:06
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment Apr 29, 2026 7:12pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
ensnode.io Skipped Skipped Apr 29, 2026 7:12pm
ensrainbow.io Skipped Skipped Apr 29, 2026 7:12pm

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 27, 2026

🦋 Changeset detected

Latest commit: bdd730e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
ensadmin Patch
ensindexer Patch
ensrainbow Patch
ensapi Patch
fallback-ensapi Patch
enssdk Patch
enscli Patch
enskit Patch
ensskills Patch
@ensnode/datasources Patch
@ensnode/ensrainbow-sdk Patch
@ensnode/ensdb-sdk Patch
@ensnode/ensnode-react Patch
@ensnode/ensnode-sdk Patch
@ensnode/integration-test-env Patch
@ensnode/ponder-sdk Patch
@ensnode/ponder-subgraph Patch
@ensnode/shared-configs Patch
@docs/ensnode Patch
@docs/ensrainbow Patch
@namehash/ens-referrals Patch
@namehash/namehash-ui Patch
@ensnode/ensindexer-perf-testing Patch
@ensnode/enskit-react-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Warning

Rate limit exceeded

@shrugs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 28 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dbe3b65c-5a57-4fb2-acb2-417802d13efb

📥 Commits

Reviewing files that changed from the base of the PR and between 24f323f and bdd730e.

📒 Files selected for processing (2)
  • .changeset/large-fans-stop.md
  • apps/ensadmin/src/components/graphiql-editor/components.tsx
📝 Walkthrough

Walkthrough

This PR optimizes the GraphiQL editor component in the ENSAdmin application by memoizing the fetcher, storage, and plugins to prevent unnecessary re-renders and schema re-introspection during frequent parent updates from the realtime indexing-status projection.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/large-fans-stop.md
Patch release note for ensadmin documenting a fix where the GraphiQL docs sidebar remains open on the omnigraph page by preventing schema re-introspection via memoization.
GraphiQL Editor Optimization
apps/ensadmin/src/components/graphiql-editor/components.tsx
Memoizes fetcher, storage, and plugins using useMemo keyed by url to prevent reconstruction on parent re-renders. Adds EMPTY_PLUGINS constant and refactors null guard placement.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A memo here, a memo there,
Plugins memoized with utmost care,
No more re-renders in the night,
GraphiQL docs stay open, bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main fix: preventing the ENSAdmin GraphiQL docs sidebar from closing during parent re-renders.
Description check ✅ Passed The description follows the template with all required sections (Summary, Why, Testing, Notes, Checklist) completed and provides clear technical detail about the memoization fix and its rationale.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch notrab/fix-ensadmin-graphiql-introspection-loop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 49 minutes and 28 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR memoizes fetcher, storage, and plugins in GraphiQLEditor to prevent GraphiQL from re-running schema introspection on every 1 Hz parent re-render driven by useIndexingStatusWithSwr. The clear() implementation is also fixed to be namespace-scoped rather than wiping all of localStorage, and the storage.length property is promoted to a live getter so it reflects current state rather than a stale snapshot from initialization time.

Confidence Score: 5/5

Safe to merge — no P0/P1 issues found; both previously flagged concerns have been addressed.

All hooks run unconditionally before the early-return guard, the SSR guard inside the storage memo prevents server-side localStorage access, explorerPlugin() is isolated in its own useMemo([]) for stability, and neither current caller passes a plugins value so EMPTY_PLUGINS fully closes the re-render loop.

No files require special attention.

Important Files Changed

Filename Overview
apps/ensadmin/src/components/graphiql-editor/components.tsx Memoizes fetcher/storage/explorer/mergedPlugins to stabilize references across re-renders; fixes scoped clear() and live length getter; SSR guard correctly placed inside storage memo body. Both callers use default EMPTY_PLUGINS so the stable-reference fix is fully effective.
.changeset/large-fans-stop.md Standard patch changeset for ensadmin package; description matches the implemented changes.

Sequence Diagram

sequenceDiagram
    participant Parent as OmnigraphPage (1Hz tick)
    participant GE as GraphiQLEditor
    participant Memo as useMemo cache
    participant GQL as GraphiQL
    participant API as /api/omnigraph

    Note over Parent,API: Before this PR
    Parent->>GE: re-render (url unchanged)
    GE->>GQL: new fetcher reference
    GQL->>API: schema introspection re-triggered
    Note over GQL: Docs sidebar resets

    Note over Parent,API: After this PR
    Parent->>GE: re-render (url unchanged)
    GE->>Memo: useMemo([url]) same fetcher
    GE->>Memo: useMemo([url]) same storage
    GE->>Memo: useMemo([]) same explorer
    GE->>GQL: same fetcher/storage/plugins refs
    Note over GQL: No introspection re-run
Loading

Reviews (4): Last reviewed commit: "revert: keep explorerPlugin per-instance..." | Re-trigger Greptile

Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx
Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes ENSAdmin’s GraphiQL docs sidebar not staying open on the omnigraph page by stabilizing key GraphiQL prop references across frequent parent re-renders, preventing repeated schema re-introspection.

Changes:

  • Memoize the GraphiQL fetcher, storage, and plugins to keep stable references across renders.
  • Hoist the default plugins value to a module-level constant to avoid busting memoization.
  • Add a changeset documenting the patch release.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
apps/ensadmin/src/components/graphiql-editor/components.tsx Memoizes fetcher/storage/plugins to prevent GraphiQL schema re-introspection and UI resets on frequent parent renders.
.changeset/large-fans-stop.md Adds a patch changeset describing the GraphiQL docs sidebar fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx
Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx Outdated
Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/large-fans-stop.md:
- Line 5: The changeset's release-note paragraph is missing a terminal period;
open the changeset's release-note paragraph (the sentence beginning "Fix
ENSAdmin GraphiQL docs sidebar...") and add a period at the end so the paragraph
ends with proper punctuation.

In `@apps/ensadmin/src/components/graphiql-editor/components.tsx`:
- Around line 50-52: The current clear() implementation calls
localStorage.clear() which wipes all origin storage; change clear() in
components.tsx to only remove keys that start with the GraphiQL namespace (the
`ensnode:graphiql:${url}` prefix) by iterating localStorage keys and calling
localStorage.removeItem(key) for matches so only per-URL namespaced entries are
deleted; ensure you reference the same `url`/prefix construction used elsewhere
to compute the namespace.
- Around line 43-64: The storage useMemo factory currently accesses
localStorage.length eagerly (in storage = useMemo(...)) which runs during render
and will throw during SSR before the later typeof window guard; fix by moving
the typeof window check into the useMemo factory (or return a safe fallback) and
make length a lazy getter that reads localStorage.length at access time (and
ensure getItem/setItem/removeItem/clear all reference window.localStorage inside
their functions rather than capturing it at memo time). Update the storage
useMemo so it returns a safe no-op storage when window/localStorage is
unavailable or defines length as a getter to avoid SSR crashes and stale
snapshot values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 21fc13fd-6eab-4768-bad9-45694bf296fc

📥 Commits

Reviewing files that changed from the base of the PR and between c186ad8 and 24f323f.

📒 Files selected for processing (2)
  • .changeset/large-fans-stop.md
  • apps/ensadmin/src/components/graphiql-editor/components.tsx

Comment thread .changeset/large-fans-stop.md Outdated
Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx
Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx
Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx Outdated
Comment thread apps/ensadmin/src/components/graphiql-editor/components.tsx Outdated
- Guard storage useMemo body against SSR (typeof window check) so localStorage
  access doesn't throw before the early-return; also makes length a getter so
  it's no longer a stale snapshot.
- Restrict storage.clear() to the per-URL namespace prefix so it stops wiping
  unrelated ENSAdmin localStorage state.
- Hoist explorerPlugin() into its own useMemo with [] deps so callers passing
  an unstable plugins array don't reset the explorer instance.
- Trailing period in changeset.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shrugs
Copy link
Copy Markdown
Member

shrugs commented Apr 29, 2026

@greptile review

Replace useMemo([]) with a plain module-level const since the plugin takes
no inputs and a stable reference is all we need.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io April 29, 2026 19:02 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensnode.io April 29, 2026 19:02 Inactive
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The explorer plugin holds editor-scoped state, so a single shared instance
would clobber state across multiple GraphiQL editors mounted simultaneously.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io April 29, 2026 19:11 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensnode.io April 29, 2026 19:11 Inactive
@shrugs
Copy link
Copy Markdown
Member

shrugs commented Apr 29, 2026

@greptile review

@shrugs shrugs merged commit 7c1c048 into main Apr 29, 2026
20 checks passed
@shrugs shrugs deleted the notrab/fix-ensadmin-graphiql-introspection-loop branch April 29, 2026 19:17
@github-actions github-actions Bot mentioned this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants